
package com.daka.entity;

import com.daka.tools.DateUtil;
import lombok.Data;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.type.Alias;

import java.text.ParseException;
import java.util.Date;

@Data
@ToString
@Alias(value = "U_VOLUNTEER_INSURANCE")
@SuppressWarnings("unused")
@Slf4j
public class VolunteerInsurance {
    /**
     * .
     */
    private Long id;

    /**
     * .
     */
    private Date createTime;

    /**
     * .
     */
    private String insuranceNo;

    /**
     * .
     */
    private String periodEnd;

    /**
     * .
     */
    private String periodStart;

    /**
     * .
     */
    private String serviceProvider;

    /**
     * .
     */
    private String serviceProviderUrl;

    /**
     * .
     */
    private Integer status;

    /**
     * .
     */
    private String volunteerCode;

    public static VolunteerInsurance build(MemberInsurance memberInsurance) {
        VolunteerInsurance volunteerInsurance = new VolunteerInsurance();

        volunteerInsurance.setVolunteerCode(memberInsurance.getVolunteercode());

        Date date;
        try {
            date = DateUtil.str2Date(memberInsurance.getCreatetime(), DateUtil.DATETIME_YYYY_MM_DD_HH_MM_SS);
        } catch (Exception e) {
            date = new Date();
            log.error("===============dakaqi============== Date Format Error! MemberInsurance Insuranceno : " + memberInsurance.getInsuranceno() );
        }

        volunteerInsurance.setCreateTime(date);
        volunteerInsurance.setInsuranceNo(memberInsurance.getInsuranceno());
        volunteerInsurance.setPeriodEnd(memberInsurance.getPeriodEnd());
        volunteerInsurance.setPeriodStart(memberInsurance.getPeriodStart());
        volunteerInsurance.setServiceProvider(memberInsurance.getServiceProvider());
        volunteerInsurance.setServiceProviderUrl(memberInsurance.getServiceProviderUrl());
        volunteerInsurance.setStatus(memberInsurance.getStatus());

        return volunteerInsurance;
    }

}